exports.MMStoreMenu = GL2.Node.subclass(
{
    classname: 'MMStoreMenu',
    
    initialize: function() 
    {
		this._backgroundImage = null;
		this._closeButton = null;
		this._shopButton = null;
		this._decorationButton = null;
		this._floorButton = null;
		this._liftButton = null;
		this._menuTopLabel = null;
		this._storeTableView = null;
    },
	
	createView: function() 
	{
		this.makeTouchSwallower();
		
		var backgroundImagePath = this.getBaseResourcePath() + "main-menu-background.png";
		
		var closeButtonImageNormal = this.getBaseResourcePath() + "close-button-normal.png"
		var closeButtonImagePressed = this.getBaseResourcePath() + "close-button-pressed.png"
			
		var genericButtonImagePathNormal = this.getBaseResourcePath() + "button-normal.png"
		var genericButtonImagePathPressed = this.getBaseResourcePath() + "button-pressed.png"

		this._backgroundImage = GLFactory.getSprite([TCUtil.getAdjustedX(0),TCUtil.getAdjustedY(45)], null, backgroundImagePath, [TCUtil.getAdjustedX(320),TCUtil.getAdjustedY(380)]);
		this.addChild(this._backgroundImage);
		
		this._menuTopLabel = GLFactory.getText([TCUtil.getAdjustedX(110), TCUtil.getAdjustedY(30)], 100,"STORE", [TCUtil.getAdjustedX(100), TCUtil.getAdjustedY(50)], TCUtil.getAdjustedFontSize(120), null, null, GL2.Text.OverflowMode.ReduceFontSize, [0.0, 0.5], new Core.Color(0,0,0));
		this._backgroundImage.addChild(this._menuTopLabel);
		
		this._closeButton = new GLButton(closeButtonImageNormal, closeButtonImagePressed, TCUtil.getAdjustedX(40),TCUtil.getAdjustedY(40), this.onCloseTouch.bind(this), this._backgroundImage, 3, "", null, null, null,null);
		this._closeButton.setPosition(TCUtil.getAdjustedX(280), TCUtil.getAdjustedY(25));
		
		this._shopButton = new GLButton(genericButtonImagePathNormal, genericButtonImagePathPressed, TCUtil.getAdjustedX(80),TCUtil.getAdjustedY(80), this.onShopButtonTouch.bind(this), this._backgroundImage, 3, "SHOPS",  new Core.Color(0,0,0), null, null, TCUtil.getAdjustedFontSize(90));
		this._shopButton.setPosition(TCUtil.getAdjustedX(75),TCUtil.getAdjustedY(85));
		
		this._decorationButton = new GLButton(genericButtonImagePathNormal, genericButtonImagePathPressed, TCUtil.getAdjustedX(80),TCUtil.getAdjustedY(80), this.onDecorationButtonTouch.bind(this), this._backgroundImage, 3, "DECORATION",  new Core.Color(0,0,0), null, null, TCUtil.getAdjustedFontSize(90));
		this._decorationButton.setPosition(TCUtil.getAdjustedX(163),TCUtil.getAdjustedY(85));
	
		this._liftButton = new GLButton(genericButtonImagePathNormal, genericButtonImagePathPressed, TCUtil.getAdjustedX(80),TCUtil.getAdjustedY(80), this.onLiftButtonTouch.bind(this), this._backgroundImage, 3, "LIFT",  new Core.Color(0,0,0), null, null, TCUtil.getAdjustedFontSize(90));
		this._liftButton.setPosition(TCUtil.getAdjustedX(250),TCUtil.getAdjustedY(85));
	},  
	
	makeTouchSwallower: function()
    {
    	var width = 0 , height = 0;
    	width = Core.Capabilities.getScreenWidth();
		height = Core.Capabilities.getScreenHeight();
        
    	this._dissolveTouchesTarget = new GL2.TouchTarget();
    	this._dissolveTouchesTarget.setAnchor(0,0);
		this._dissolveTouchesTarget.setSize(TCUtil.getAdjustedX(width),TCUtil.getAdjustedY(height));
        this._dissolveTouchesTarget.setPosition(TCUtil.getAdjustedY(0),TCUtil.getAdjustedX(0));
     
        this._myMessageListener = new Core.MessageListener();
		this._dissolveTouchesTarget.getTouchEmitter().addListener(this._myMessageListener, this.dissolveTouches.bind(this),10); //@ make this 10 go to Constants.
		this.addChild(this._dissolveTouchesTarget);
    },
    
    dissolveTouches: function()
    {
    	return true;
    },
	
	
	onCloseTouch: function ()
	{
		this.destroy();
	},
	
	onShopButtonTouch: function()
	{
		//console.log('zaki:::::::::::::::::: store');
		this.destroy();
		var storeId = '1';
		var categoryId = '1';
		this._storeMainView =  new StoreMainView(storeId, categoryId);
		this._storeMainView.createView();
		NGWindow.document.addChild(this._storeMainView);
	},
	
	onDecorationButtonTouch: function()
	{
		//console.log('zaki:::::::::::::::::: decoration');
		this.destroy();
		var storeId = '2';
		var categoryId = '1';
		this._storeMainView =  new StoreMainView(storeId, categoryId);
		this._storeMainView.createView();
		NGWindow.document.addChild(this._storeMainView);
	},
	
	onFloorButtonTouch: function()
	{
		//console.log('zaki:::::::::::::::::: floor');
		MMGameLayer.getMallUI().addFloor();
		this.destroy();
//		var storeId = '3';
//		var categoryId = '1';
//		this._storeMainView =  new StoreMainView(storeId, categoryId);
//		this._storeMainView.createView();
//		NGWindow.document.addChild(this._storeMainView);
	},
	
	onLiftButtonTouch: function()
	{
		//console.log('zaki:::::::::::::::::: lift');
		this.destroy();
		var storeId = '4';
		var categoryId = '1';
		this._storeMainView =  new StoreMainView(storeId, categoryId);
		this._storeMainView.createView();
		NGWindow.document.addChild(this._storeMainView);
	},
	
	getBaseResourcePath: function()
	{
		return "./Content/images/gamelayer/controllayer/storemenu/";
	},
	
	destroy: function ()
	{
		if(this._backgroundImage)
		{
			this._backgroundImage.destroy();
			this._backgroundImage = null;
		}
		if(this._closeButton)
		{
			this._closeButton.destroy();
			this._closeButton = null;
		}
		if(this._menuTopLabel)
		{
			this._menuTopLabel.destroy();
			this._menuTopLabel = null;
		}
		if(this._dissolveTouchesTarget)
		{
			this._dissolveTouchesTarget.destroy();
			this._dissolveTouchesTarget = null;
		}
		if(this._myMessageListener)
		{
			this._myMessageListener.destroy();
			this._myMessageListener = null;
		}
		if(this._shopButton)
		{
			this._shopButton.destroy();
			this._shopButton = null;
		}
		if(this._decorationButton)
		{
			this._decorationButton.destroy();
			this._decorationButton = null;
		}
		if(this._floorButton)
		{
			this._floorButton.destroy();
			this._floorButton = null;
		}
		if(this._liftButton)
		{
			this._liftButton.destroy();
			this._liftButton = null;
		}
	}
});